Skip to content

feat(wasserfoerderung): draw Förderstrecken on a map with real elevation profiles (#150, Plan B) - #164

Merged
DeepDiver1975 merged 4 commits into
feat/wasserfoerderung-plan-afrom
feat/wasserfoerderung-plan-b
Aug 31, 2026
Merged

DeepDiver1975 merged 4 commits into
feat/wasserfoerderung-plan-afrom
feat/wasserfoerderung-plan-b

Conversation

@DeepDiver1975

@DeepDiver1975 DeepDiver1975 commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Zusammenfassung

Phase 2 von #150 (nach Plan A / #152): der Operator kann eine Wasserförderungs-Leitung jetzt auf einer Karte einzeichnen, statt Länge/Höhenunterschied von Hand einzutippen. Das Geländeprofil wird entlang der gezeichneten Route aus einem gebündelten DEM (eigenes Binärformat) gesampelt, und die Pumpenplatzierung wird streckenweise gegen das tatsächliche Profil berechnet statt gegen eine einzelne, gleichmäßige Steigung — dadurch werden innenliegende Kuppen (Anstieg + Abstieg zurück auf dieselbe Nettohöhe) erkannt, die die flache Plan-A-Formel übersehen würde.

Kartenkacheln kommen aus einer gebündelten MBTiles-Datei; beide Dateien werden über eine neue globale Stammdaten-Einstellung „Einsatzgebiet" referenziert. Vollständig offline wie der Rest der App, keine neue NuGet-Abhängigkeit: MBTiles wird über das bereits referenzierte Microsoft.Data.Sqlite gelesen, die Kartenansicht ist ein selbstgebautes Avalonia-Control mit Standard-Web-Mercator-Kachel-Mathematik. Die manuelle Eingabe (Plan A) bleibt unverändert verfügbar, überall wo kein Einsatzgebiet konfiguriert ist. Die Route bekommt zusätzlich einen kleinen Karten-Schnappschuss im PDF-Export neben ihrer Zahlenzeile.

Base-Branch ist feat/wasserfoerderung-plan-a (#152), da Phase 1 noch nicht in main gemerged ist — dieser PR baut auf Migration v18/Domain-Code von Plan A auf.

  • Domain-Fix: FörderstreckePlanner.PlanFromProfile läuft das Profil Bein für Bein ab und verfolgt das laufende Maximum des kumulativen Druckabfalls statt nur den Endpunkt zu prüfen — Plan A (Plan(...)) delegiert jetzt intern dorthin und bleibt für alle 9 bestehenden Tests bytegleich.
  • Persistenz: DemFileElevationSampler (eigenes DEM-Binärformat, bilineare Interpolation, NoData-/Außerhalb-Behandlung), MbTilesFileSource (TMS↔XYZ-Kachel-Mathematik).
  • Stammdaten: neue globale Sektion „Einsatzgebiet" (Name + Ordnerpfad zu region.mbtiles/region.dem).
  • Migration v19: route_points_json (NULL = manuelle Plan-A-Eingabe).
  • Sync: vollständige Befehlskette (Command → Applier → Snapshot → beide Session-Typen).
  • UI: MapCanvasControl (neues Custom-Control) + WebMercator-Kachel-Mathematik; Manuell/Karte-Umschalter im WASSERFÖRDERUNG-Tab.
  • PDF: IRouteOverviewRenderer-Port + Implementierung, bettet einen Karten-Schnappschuss pro routenbasierter Leitung ein.

Tests

826 → 882 Tests grün (54 neue, keine Regressionen).

Screenshots

Screenshots rendered via the headless test harness — paste them in below (see file paths in the session).

Bekannte Einschränkungen (bewusste Entscheidungen für diesen Umfang)

  • Kein Kartenschwenken per Drag — die Karte öffnet auf einem festen Standardmittelpunkt mit Zoom +/- Buttons.
  • Werkzeuge zum Erstellen/Verwalten der MBTiles/DEM-Pakete für beliebige Regionen sind bewusst Phase 3 vorbehalten (feat: plan mode for wasserförderung #150).

🤖 Generated with Claude Code

https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2

…ion profiles (#150, Plan B)

Phase 2 of #150: lets the operator draw a Wasserförderung route on a map
instead of typing length/rise by hand. Terrain is sampled from a bundled
DEM (custom binary heightmap) along the drawn polyline, and pump
placement is computed leg-by-leg against the actual profile instead of
assuming one uniform gradient — catching interior crests (a climb then
descent back to the same net height) that the flat Plan A formula would
miss. Map tiles come from a bundled MBTiles file, both referenced from a
new "Einsatzgebiet" (region of operation) global Stammdaten setting.

Fully offline like the rest of the app, no new NuGet dependency: MBTiles
is read via the already-referenced Microsoft.Data.Sqlite, and the map
canvas is a hand-rolled Avalonia control using standard Web Mercator
tile math. Manuell (Plan A) entry stays available unchanged wherever a
region isn't configured. The route also gets a small map snapshot
embedded in the PDF export next to its numeric row.

826 -> 882 tests, all green.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
… at small windows

The Karte-mode layout used a DockPanel with a fixed Height="360" map
plus stacked Bottom-docked input-dock panels and no ScrollViewer. In a
window short enough that the DataGrid's share of the DockPanel
collapsed to zero (confirmed at 1920x700), the map Border — later in
Z-order — rendered on top of and overlapped the mode-toggle header
buttons instead of being pushed below them. Separately, the Karte
input dock's unwrapped horizontal button row pushed "FERTIG" past the
window's right edge entirely at narrower widths (confirmed at 1080
wide).

Root-caused by reproducing both at exact window sizes via the headless
harness (not by guessing from the screenshot) after an initial
attempt to reproduce via the live desktop app under Xvfb touched a
real incident file's mtime through its native open dialog — that
route was abandoned once caught.

Fix: wrap everything below the header in a single ScrollViewer with
naturally-stacked content (same pattern already used by
ChecklistView/FilesView/etc. in this codebase) so insufficient space
scrolls instead of overlaps, and switch both input docks' button rows
from an unwrapped horizontal StackPanel to a WrapPanel so buttons wrap
instead of overflowing the window.

New regression test asserts the map never starts above the header's
bottom edge and FERTIG's right edge never exceeds the window width, at
the exact size that reproduced the bug.

882 -> 883 tests, all green.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
…150) (#168)

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150)

Stammdaten's Einsatzgebiet config was a raw folder-path text field with no
way to actually get map data onto a machine. Replace it with a dropdown
fed by a published region-pack catalog (regions.json + GitHub Releases,
one pack per Landkreis): pick a region, hit "Herunterladen", the app
fetches and extracts region.mbtiles/region.dem via IRegionPackCatalogService
and IRegionPackInstaller. Manual folder entry stays available under an
"Erweitert" fallback for a self-built or hand-placed pack.

The pack-building side (osmium extract, raster tile rendering, SRTM
elevation conversion) stays a documented external runbook under
tools/build-region-pack/, deliberately kept out of LageBuch.sln — it's a
one-time-per-region maintainer task, not something every installation
needs to run itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): reject path-traversal slugs in region-pack manifest

RegionPackInstaller joins pack.Slug straight onto the regions base
directory (<regionsBaseDir>/<slug>). Since regions.json is fetched from a
third-party-controlled URL, a manifest entry with a slug like "../../etc"
could extract a downloaded pack outside the regions directory.

Reject unsafe slugs at parse time in RegionPackCatalogJson (same
"malformed entry is skipped, not thrown" defensive style already used for
missing/wrong-typed fields), and add a defense-in-depth path-containment
check in RegionPackInstaller itself in case a slug ever reaches it another
way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…eal tiles (#169)

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150)

Stammdaten's Einsatzgebiet config was a raw folder-path text field with no
way to actually get map data onto a machine. Replace it with a dropdown
fed by a published region-pack catalog (regions.json + GitHub Releases,
one pack per Landkreis): pick a region, hit "Herunterladen", the app
fetches and extracts region.mbtiles/region.dem via IRegionPackCatalogService
and IRegionPackInstaller. Manual folder entry stays available under an
"Erweitert" fallback for a self-built or hand-placed pack.

The pack-building side (osmium extract, raster tile rendering, SRTM
elevation conversion) stays a documented external runbook under
tools/build-region-pack/, deliberately kept out of LageBuch.sln — it's a
one-time-per-region maintainer task, not something every installation
needs to run itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): reject path-traversal slugs in region-pack manifest

RegionPackInstaller joins pack.Slug straight onto the regions base
directory (<regionsBaseDir>/<slug>). Since regions.json is fetched from a
third-party-controlled URL, a manifest entry with a slug like "../../etc"
could extract a downloaded pack outside the regions directory.

Reject unsafe slugs at parse time in RegionPackCatalogJson (same
"malformed entry is skipped, not thrown" defensive style already used for
missing/wrong-typed fields), and add a defense-in-depth path-containment
check in RegionPackInstaller itself in case a slug ever reaches it another
way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): center Karte mode on the configured region's real tiles

Root cause (systematic-debugging): WasserfoerderungViewModel's initial map
center/zoom were a hardcoded constant (48.14, 11.58 — near Munich) picked
before any Einsatzgebiet had a knowable location. The real, published
Fürstenfeldbruck pack's tiles don't cover that point at all (z14 tile
column 8719 vs. the pack's actual [8691,8712] range), so Karte mode opened
on a blank map with no visible tiles — matching the report exactly.

Fix: derive the initial view from the tiles the configured region.mbtiles
actually has, via a new IMapTileSource.GetTileBounds() (lowest zoom level
present, TMS rows flipped back to XYZ), converted to a center through
WebMercator — moved from LageBuch.App.Shared to LageBuch.AppLogic since
IncidentWorkspaceViewModel now needs it too. This self-corrects for any
region (downloaded or manually placed under "Erweitert") since it reads
the actual tile data rather than trusting separately-tracked metadata.
The hardcoded fallback stays for the truly-no-tiles case.

Verified against the real published Fürstenfeldbruck pack: Karte mode now
opens already showing Fürstenfeldbruck/Olching/Puchheim/Germering, not a
blank canvas.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): add wheel/pinch zoom and overzoom to Karte mode (#170)

* fix(wasserfoerderung): add wheel/pinch zoom and overzoom to Karte mode

Reported: "I cannot zoom into the map data" (initially proposed introducing
Mapsui). Investigated first: MapCanvasControl had no scroll-wheel or pinch
zoom at all -- only two tiny +/- buttons -- and WasserfoerderungViewModel's
MinZoom/MaxZoom were fixed constants (3/19) unrelated to what the
configured region's region.mbtiles actually contains. The real,
published Fürstenfeldbruck pack only renders z11-15; MapDrawing silently
skipped any missing tile, so clicking + past z15 or - past z11 showed a
blank canvas with zero feedback. Mapsui would fix this too, but at real
cost (this app's first third-party dependency, blocked on Android today
since it needs Avalonia >=11.3.1 and Android is pinned to 11.2.2, and a
much bigger rewrite than the bug needs) -- fixed the actual root cause
instead.

- IMapTileSource.GetMaxZoom() (MbTilesFileSource: SELECT MAX(zoom_level)).
- WasserfoerderungViewModel: per-region MinZoom (from the same
  GetTileBounds() the center fix already computes -- the region's own
  lowest rendered zoom), a new ChangeMapViewCommand(MapViewChange) command
  applying a wheel/pinch-driven view change, clamped to Min/MaxZoom.
- MapCanvasControl: OnPointerWheelChanged and a PinchGestureRecognizer
  handler, both zooming while keeping the gesture's focal point
  geographically stationary, routed through the new ViewChangedCommand
  (matching the control's existing PointClickedCommand/UndoRequestedCommand
  pattern rather than two-way property binding).
- MapDrawing.DrawTiles: when the exact tile is missing past the source's
  actual max zoom, draws a cropped ancestor tile from the max zoom instead
  ("overzoom" -- standard map-app behavior past native detail).

Verified against the real published Fürstenfeldbruck pack: scrolling in
6 levels past z15 shows a legible overzoomed view (not blank); scrolling
out clamps cleanly at z11 (the pack's real minimum), never blank.

Pinch-to-zoom's scale->zoom-delta math is unit-tested directly
(Avalonia.Headless has no touch/gesture simulation API to drive the full
gesture pipeline).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): require Ctrl for wheel-zoom so plain scroll reaches the page

Root cause (systematic-debugging): the wheel-zoom just added in this same
branch unconditionally captured every wheel event over MapCanvasControl
(e.Handled = true, no modifier check). The map sits inside the
Wasserförderung tab's own ScrollViewer (WasserfoerderungView.axaml) at
360px tall — on a laptop where the window is short enough that the tab
needs to scroll, the cursor is very likely to land on the map while the
operator scrolls the page. Every such scroll got swallowed as a zoom
instead of reaching the ScrollViewer, and a laptop trackpad's rapid
wheel-delta stream during a single scroll swipe could zoom dozens of
levels in an instant — "renders it unreadable," exactly as reported.

Fix: gate wheel-zoom on Ctrl (KeyModifiers.Control), matching how most
embedded maps resolve this exact conflict (Leaflet, Google Maps embeds,
etc.). Plain scroll no longer sets e.Handled, so it bubbles to the
ScrollViewer as normal; Ctrl+scroll still zooms exactly as before,
keeping the cursor's geo point stationary. Pinch-to-zoom is unaffected —
a pinch gesture doesn't conflict with page-scroll the way a plain wheel
notch does.

Verified against the real published Fürstenfeldbruck pack: plain scroll
over the map no longer changes zoom; Ctrl+scroll still zooms in by one
level as designed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): add Ctrl+drag pan and a reset-view control to Karte mode

Root cause (systematic-debugging): cursor-anchored wheel/pinch zoom
shifts the map's center as a side effect (correct, by design), but
MapCanvasControl had no drag-to-pan at all and WasserfoerderungViewModel
never kept the region's initial center/zoom anywhere. Once the view
drifted away from the configured region (trivial after a few zooms near
an edge), there was no way back at all -- matching the report exactly.
Considered Mapsui again; same conclusion as before (first third-party
dependency, blocked on Android's Avalonia pin, much bigger than this
gap needs) -- added the missing controls to the existing hand-rolled map
instead.

- WasserfoerderungViewModel: stores the view it opened with and exposes
  a new ResetMapViewCommand ("ZENTRIEREN") that returns to it.
- MapCanvasControl: Ctrl+left-drag pans (moving the center opposite the
  drag direction, standard map UX), routed through the same
  ViewChangedCommand as wheel/pinch zoom. Reuses the Ctrl convention
  already established for zoom, so it never risks being confused with
  the primary plain-left-click-to-draw-a-route-point gesture.
- Added a small "Strg + Scrollen: Zoom / Strg + Ziehen: Verschieben"
  hint next to the new button, since both interactions are otherwise
  undiscoverable.

Also fixed a real regression these additions exposed: the extra button
and hint line made the tab tall enough to trigger the outer
ScrollViewer's (Fluent overlay-style) vertical scrollbar at window sizes
that previously fit without scrolling. That scrollbar renders on top of
-- not narrowing -- the content, so it silently swallowed clicks on the
map's own right edge. Fixed by reserving a right margin matching the
scrollbar's width, so real content never sits flush against that edge
regardless of what triggers scrolling in the future.

Verified against the real published Fürstenfeldbruck pack: drifting the
view to Berlin, then Ctrl+drag panning and clicking ZENTRIEREN, both
bring it back to Fürstenfeldbruck exactly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@DeepDiver1975
DeepDiver1975 merged commit e19f955 into feat/wasserfoerderung-plan-a Aug 31, 2026
2 checks passed
@DeepDiver1975
DeepDiver1975 deleted the feat/wasserfoerderung-plan-b branch August 31, 2026 15:59
DeepDiver1975 added a commit that referenced this pull request Sep 2, 2026
…ion profiles (#150, Plan B) (#164)

* feat(wasserfoerderung): draw Förderstrecken on a map with real elevation profiles (#150, Plan B)

Phase 2 of #150: lets the operator draw a Wasserförderung route on a map
instead of typing length/rise by hand. Terrain is sampled from a bundled
DEM (custom binary heightmap) along the drawn polyline, and pump
placement is computed leg-by-leg against the actual profile instead of
assuming one uniform gradient — catching interior crests (a climb then
descent back to the same net height) that the flat Plan A formula would
miss. Map tiles come from a bundled MBTiles file, both referenced from a
new "Einsatzgebiet" (region of operation) global Stammdaten setting.

Fully offline like the rest of the app, no new NuGet dependency: MBTiles
is read via the already-referenced Microsoft.Data.Sqlite, and the map
canvas is a hand-rolled Avalonia control using standard Web Mercator
tile math. Manuell (Plan A) entry stays available unchanged wherever a
region isn't configured. The route also gets a small map snapshot
embedded in the PDF export next to its numeric row.

826 -> 882 tests, all green.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): stop Karte-mode content overlapping the header at small windows

The Karte-mode layout used a DockPanel with a fixed Height="360" map
plus stacked Bottom-docked input-dock panels and no ScrollViewer. In a
window short enough that the DataGrid's share of the DockPanel
collapsed to zero (confirmed at 1920x700), the map Border — later in
Z-order — rendered on top of and overlapped the mode-toggle header
buttons instead of being pushed below them. Separately, the Karte
input dock's unwrapped horizontal button row pushed "FERTIG" past the
window's right edge entirely at narrower widths (confirmed at 1080
wide).

Root-caused by reproducing both at exact window sizes via the headless
harness (not by guessing from the screenshot) after an initial
attempt to reproduce via the live desktop app under Xvfb touched a
real incident file's mtime through its native open dialog — that
route was abandoned once caught.

Fix: wrap everything below the header in a single ScrollViewer with
naturally-stacked content (same pattern already used by
ChecklistView/FilesView/etc. in this codebase) so insufficient space
scrolls instead of overlaps, and switch both input docks' button rows
from an unwrapped horizontal StackPanel to a WrapPanel so buttons wrap
instead of overflowing the window.

New regression test asserts the map never starts above the header's
bottom edge and FERTIG's right edge never exceeds the window width, at
the exact size that reproduced the bug.

882 -> 883 tests, all green.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150) (#168)

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150)

Stammdaten's Einsatzgebiet config was a raw folder-path text field with no
way to actually get map data onto a machine. Replace it with a dropdown
fed by a published region-pack catalog (regions.json + GitHub Releases,
one pack per Landkreis): pick a region, hit "Herunterladen", the app
fetches and extracts region.mbtiles/region.dem via IRegionPackCatalogService
and IRegionPackInstaller. Manual folder entry stays available under an
"Erweitert" fallback for a self-built or hand-placed pack.

The pack-building side (osmium extract, raster tile rendering, SRTM
elevation conversion) stays a documented external runbook under
tools/build-region-pack/, deliberately kept out of LageBuch.sln — it's a
one-time-per-region maintainer task, not something every installation
needs to run itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): reject path-traversal slugs in region-pack manifest

RegionPackInstaller joins pack.Slug straight onto the regions base
directory (<regionsBaseDir>/<slug>). Since regions.json is fetched from a
third-party-controlled URL, a manifest entry with a slug like "../../etc"
could extract a downloaded pack outside the regions directory.

Reject unsafe slugs at parse time in RegionPackCatalogJson (same
"malformed entry is skipped, not thrown" defensive style already used for
missing/wrong-typed fields), and add a defense-in-depth path-containment
check in RegionPackInstaller itself in case a slug ever reaches it another
way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

* fix(wasserfoerderung): center Karte mode on the configured region's real tiles (#169)

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150)

Stammdaten's Einsatzgebiet config was a raw folder-path text field with no
way to actually get map data onto a machine. Replace it with a dropdown
fed by a published region-pack catalog (regions.json + GitHub Releases,
one pack per Landkreis): pick a region, hit "Herunterladen", the app
fetches and extracts region.mbtiles/region.dem via IRegionPackCatalogService
and IRegionPackInstaller. Manual folder entry stays available under an
"Erweitert" fallback for a self-built or hand-placed pack.

The pack-building side (osmium extract, raster tile rendering, SRTM
elevation conversion) stays a documented external runbook under
tools/build-region-pack/, deliberately kept out of LageBuch.sln — it's a
one-time-per-region maintainer task, not something every installation
needs to run itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): reject path-traversal slugs in region-pack manifest

RegionPackInstaller joins pack.Slug straight onto the regions base
directory (<regionsBaseDir>/<slug>). Since regions.json is fetched from a
third-party-controlled URL, a manifest entry with a slug like "../../etc"
could extract a downloaded pack outside the regions directory.

Reject unsafe slugs at parse time in RegionPackCatalogJson (same
"malformed entry is skipped, not thrown" defensive style already used for
missing/wrong-typed fields), and add a defense-in-depth path-containment
check in RegionPackInstaller itself in case a slug ever reaches it another
way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): center Karte mode on the configured region's real tiles

Root cause (systematic-debugging): WasserfoerderungViewModel's initial map
center/zoom were a hardcoded constant (48.14, 11.58 — near Munich) picked
before any Einsatzgebiet had a knowable location. The real, published
Fürstenfeldbruck pack's tiles don't cover that point at all (z14 tile
column 8719 vs. the pack's actual [8691,8712] range), so Karte mode opened
on a blank map with no visible tiles — matching the report exactly.

Fix: derive the initial view from the tiles the configured region.mbtiles
actually has, via a new IMapTileSource.GetTileBounds() (lowest zoom level
present, TMS rows flipped back to XYZ), converted to a center through
WebMercator — moved from LageBuch.App.Shared to LageBuch.AppLogic since
IncidentWorkspaceViewModel now needs it too. This self-corrects for any
region (downloaded or manually placed under "Erweitert") since it reads
the actual tile data rather than trusting separately-tracked metadata.
The hardcoded fallback stays for the truly-no-tiles case.

Verified against the real published Fürstenfeldbruck pack: Karte mode now
opens already showing Fürstenfeldbruck/Olching/Puchheim/Germering, not a
blank canvas.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): add wheel/pinch zoom and overzoom to Karte mode (#170)

* fix(wasserfoerderung): add wheel/pinch zoom and overzoom to Karte mode

Reported: "I cannot zoom into the map data" (initially proposed introducing
Mapsui). Investigated first: MapCanvasControl had no scroll-wheel or pinch
zoom at all -- only two tiny +/- buttons -- and WasserfoerderungViewModel's
MinZoom/MaxZoom were fixed constants (3/19) unrelated to what the
configured region's region.mbtiles actually contains. The real,
published Fürstenfeldbruck pack only renders z11-15; MapDrawing silently
skipped any missing tile, so clicking + past z15 or - past z11 showed a
blank canvas with zero feedback. Mapsui would fix this too, but at real
cost (this app's first third-party dependency, blocked on Android today
since it needs Avalonia >=11.3.1 and Android is pinned to 11.2.2, and a
much bigger rewrite than the bug needs) -- fixed the actual root cause
instead.

- IMapTileSource.GetMaxZoom() (MbTilesFileSource: SELECT MAX(zoom_level)).
- WasserfoerderungViewModel: per-region MinZoom (from the same
  GetTileBounds() the center fix already computes -- the region's own
  lowest rendered zoom), a new ChangeMapViewCommand(MapViewChange) command
  applying a wheel/pinch-driven view change, clamped to Min/MaxZoom.
- MapCanvasControl: OnPointerWheelChanged and a PinchGestureRecognizer
  handler, both zooming while keeping the gesture's focal point
  geographically stationary, routed through the new ViewChangedCommand
  (matching the control's existing PointClickedCommand/UndoRequestedCommand
  pattern rather than two-way property binding).
- MapDrawing.DrawTiles: when the exact tile is missing past the source's
  actual max zoom, draws a cropped ancestor tile from the max zoom instead
  ("overzoom" -- standard map-app behavior past native detail).

Verified against the real published Fürstenfeldbruck pack: scrolling in
6 levels past z15 shows a legible overzoomed view (not blank); scrolling
out clamps cleanly at z11 (the pack's real minimum), never blank.

Pinch-to-zoom's scale->zoom-delta math is unit-tested directly
(Avalonia.Headless has no touch/gesture simulation API to drive the full
gesture pipeline).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): require Ctrl for wheel-zoom so plain scroll reaches the page

Root cause (systematic-debugging): the wheel-zoom just added in this same
branch unconditionally captured every wheel event over MapCanvasControl
(e.Handled = true, no modifier check). The map sits inside the
Wasserförderung tab's own ScrollViewer (WasserfoerderungView.axaml) at
360px tall — on a laptop where the window is short enough that the tab
needs to scroll, the cursor is very likely to land on the map while the
operator scrolls the page. Every such scroll got swallowed as a zoom
instead of reaching the ScrollViewer, and a laptop trackpad's rapid
wheel-delta stream during a single scroll swipe could zoom dozens of
levels in an instant — "renders it unreadable," exactly as reported.

Fix: gate wheel-zoom on Ctrl (KeyModifiers.Control), matching how most
embedded maps resolve this exact conflict (Leaflet, Google Maps embeds,
etc.). Plain scroll no longer sets e.Handled, so it bubbles to the
ScrollViewer as normal; Ctrl+scroll still zooms exactly as before,
keeping the cursor's geo point stationary. Pinch-to-zoom is unaffected —
a pinch gesture doesn't conflict with page-scroll the way a plain wheel
notch does.

Verified against the real published Fürstenfeldbruck pack: plain scroll
over the map no longer changes zoom; Ctrl+scroll still zooms in by one
level as designed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): add Ctrl+drag pan and a reset-view control to Karte mode

Root cause (systematic-debugging): cursor-anchored wheel/pinch zoom
shifts the map's center as a side effect (correct, by design), but
MapCanvasControl had no drag-to-pan at all and WasserfoerderungViewModel
never kept the region's initial center/zoom anywhere. Once the view
drifted away from the configured region (trivial after a few zooms near
an edge), there was no way back at all -- matching the report exactly.
Considered Mapsui again; same conclusion as before (first third-party
dependency, blocked on Android's Avalonia pin, much bigger than this
gap needs) -- added the missing controls to the existing hand-rolled map
instead.

- WasserfoerderungViewModel: stores the view it opened with and exposes
  a new ResetMapViewCommand ("ZENTRIEREN") that returns to it.
- MapCanvasControl: Ctrl+left-drag pans (moving the center opposite the
  drag direction, standard map UX), routed through the same
  ViewChangedCommand as wheel/pinch zoom. Reuses the Ctrl convention
  already established for zoom, so it never risks being confused with
  the primary plain-left-click-to-draw-a-route-point gesture.
- Added a small "Strg + Scrollen: Zoom / Strg + Ziehen: Verschieben"
  hint next to the new button, since both interactions are otherwise
  undiscoverable.

Also fixed a real regression these additions exposed: the extra button
and hint line made the tab tall enough to trigger the outer
ScrollViewer's (Fluent overlay-style) vertical scrollbar at window sizes
that previously fit without scrolling. That scrollbar renders on top of
-- not narrowing -- the content, so it silently swallowed clicks on the
map's own right edge. Fixed by reserving a right margin matching the
scrollbar's width, so real content never sits flush against that edge
regardless of what triggers scrolling in the future.

Verified against the real published Fürstenfeldbruck pack: drifting the
view to Berlin, then Ctrl+drag panning and clicking ZENTRIEREN, both
bring it back to Fürstenfeldbruck exactly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
DeepDiver1975 added a commit that referenced this pull request Sep 2, 2026
…ion profiles (#150, Plan B) (#164)

* feat(wasserfoerderung): draw Förderstrecken on a map with real elevation profiles (#150, Plan B)

Phase 2 of #150: lets the operator draw a Wasserförderung route on a map
instead of typing length/rise by hand. Terrain is sampled from a bundled
DEM (custom binary heightmap) along the drawn polyline, and pump
placement is computed leg-by-leg against the actual profile instead of
assuming one uniform gradient — catching interior crests (a climb then
descent back to the same net height) that the flat Plan A formula would
miss. Map tiles come from a bundled MBTiles file, both referenced from a
new "Einsatzgebiet" (region of operation) global Stammdaten setting.

Fully offline like the rest of the app, no new NuGet dependency: MBTiles
is read via the already-referenced Microsoft.Data.Sqlite, and the map
canvas is a hand-rolled Avalonia control using standard Web Mercator
tile math. Manuell (Plan A) entry stays available unchanged wherever a
region isn't configured. The route also gets a small map snapshot
embedded in the PDF export next to its numeric row.

826 -> 882 tests, all green.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): stop Karte-mode content overlapping the header at small windows

The Karte-mode layout used a DockPanel with a fixed Height="360" map
plus stacked Bottom-docked input-dock panels and no ScrollViewer. In a
window short enough that the DataGrid's share of the DockPanel
collapsed to zero (confirmed at 1920x700), the map Border — later in
Z-order — rendered on top of and overlapped the mode-toggle header
buttons instead of being pushed below them. Separately, the Karte
input dock's unwrapped horizontal button row pushed "FERTIG" past the
window's right edge entirely at narrower widths (confirmed at 1080
wide).

Root-caused by reproducing both at exact window sizes via the headless
harness (not by guessing from the screenshot) after an initial
attempt to reproduce via the live desktop app under Xvfb touched a
real incident file's mtime through its native open dialog — that
route was abandoned once caught.

Fix: wrap everything below the header in a single ScrollViewer with
naturally-stacked content (same pattern already used by
ChecklistView/FilesView/etc. in this codebase) so insufficient space
scrolls instead of overlaps, and switch both input docks' button rows
from an unwrapped horizontal StackPanel to a WrapPanel so buttons wrap
instead of overflowing the window.

New regression test asserts the map never starts above the header's
bottom edge and FERTIG's right edge never exceeds the window width, at
the exact size that reproduced the bug.

882 -> 883 tests, all green.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150) (#168)

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150)

Stammdaten's Einsatzgebiet config was a raw folder-path text field with no
way to actually get map data onto a machine. Replace it with a dropdown
fed by a published region-pack catalog (regions.json + GitHub Releases,
one pack per Landkreis): pick a region, hit "Herunterladen", the app
fetches and extracts region.mbtiles/region.dem via IRegionPackCatalogService
and IRegionPackInstaller. Manual folder entry stays available under an
"Erweitert" fallback for a self-built or hand-placed pack.

The pack-building side (osmium extract, raster tile rendering, SRTM
elevation conversion) stays a documented external runbook under
tools/build-region-pack/, deliberately kept out of LageBuch.sln — it's a
one-time-per-region maintainer task, not something every installation
needs to run itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): reject path-traversal slugs in region-pack manifest

RegionPackInstaller joins pack.Slug straight onto the regions base
directory (<regionsBaseDir>/<slug>). Since regions.json is fetched from a
third-party-controlled URL, a manifest entry with a slug like "../../etc"
could extract a downloaded pack outside the regions directory.

Reject unsafe slugs at parse time in RegionPackCatalogJson (same
"malformed entry is skipped, not thrown" defensive style already used for
missing/wrong-typed fields), and add a defense-in-depth path-containment
check in RegionPackInstaller itself in case a slug ever reaches it another
way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

* fix(wasserfoerderung): center Karte mode on the configured region's real tiles (#169)

* feat(wasserfoerderung): downloadable region packs for Einsatzgebiet (#150)

Stammdaten's Einsatzgebiet config was a raw folder-path text field with no
way to actually get map data onto a machine. Replace it with a dropdown
fed by a published region-pack catalog (regions.json + GitHub Releases,
one pack per Landkreis): pick a region, hit "Herunterladen", the app
fetches and extracts region.mbtiles/region.dem via IRegionPackCatalogService
and IRegionPackInstaller. Manual folder entry stays available under an
"Erweitert" fallback for a self-built or hand-placed pack.

The pack-building side (osmium extract, raster tile rendering, SRTM
elevation conversion) stays a documented external runbook under
tools/build-region-pack/, deliberately kept out of LageBuch.sln — it's a
one-time-per-region maintainer task, not something every installation
needs to run itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): reject path-traversal slugs in region-pack manifest

RegionPackInstaller joins pack.Slug straight onto the regions base
directory (<regionsBaseDir>/<slug>). Since regions.json is fetched from a
third-party-controlled URL, a manifest entry with a slug like "../../etc"
could extract a downloaded pack outside the regions directory.

Reject unsafe slugs at parse time in RegionPackCatalogJson (same
"malformed entry is skipped, not thrown" defensive style already used for
missing/wrong-typed fields), and add a defense-in-depth path-containment
check in RegionPackInstaller itself in case a slug ever reaches it another
way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): center Karte mode on the configured region's real tiles

Root cause (systematic-debugging): WasserfoerderungViewModel's initial map
center/zoom were a hardcoded constant (48.14, 11.58 — near Munich) picked
before any Einsatzgebiet had a knowable location. The real, published
Fürstenfeldbruck pack's tiles don't cover that point at all (z14 tile
column 8719 vs. the pack's actual [8691,8712] range), so Karte mode opened
on a blank map with no visible tiles — matching the report exactly.

Fix: derive the initial view from the tiles the configured region.mbtiles
actually has, via a new IMapTileSource.GetTileBounds() (lowest zoom level
present, TMS rows flipped back to XYZ), converted to a center through
WebMercator — moved from LageBuch.App.Shared to LageBuch.AppLogic since
IncidentWorkspaceViewModel now needs it too. This self-corrects for any
region (downloaded or manually placed under "Erweitert") since it reads
the actual tile data rather than trusting separately-tracked metadata.
The hardcoded fallback stays for the truly-no-tiles case.

Verified against the real published Fürstenfeldbruck pack: Karte mode now
opens already showing Fürstenfeldbruck/Olching/Puchheim/Germering, not a
blank canvas.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): add wheel/pinch zoom and overzoom to Karte mode (#170)

* fix(wasserfoerderung): add wheel/pinch zoom and overzoom to Karte mode

Reported: "I cannot zoom into the map data" (initially proposed introducing
Mapsui). Investigated first: MapCanvasControl had no scroll-wheel or pinch
zoom at all -- only two tiny +/- buttons -- and WasserfoerderungViewModel's
MinZoom/MaxZoom were fixed constants (3/19) unrelated to what the
configured region's region.mbtiles actually contains. The real,
published Fürstenfeldbruck pack only renders z11-15; MapDrawing silently
skipped any missing tile, so clicking + past z15 or - past z11 showed a
blank canvas with zero feedback. Mapsui would fix this too, but at real
cost (this app's first third-party dependency, blocked on Android today
since it needs Avalonia >=11.3.1 and Android is pinned to 11.2.2, and a
much bigger rewrite than the bug needs) -- fixed the actual root cause
instead.

- IMapTileSource.GetMaxZoom() (MbTilesFileSource: SELECT MAX(zoom_level)).
- WasserfoerderungViewModel: per-region MinZoom (from the same
  GetTileBounds() the center fix already computes -- the region's own
  lowest rendered zoom), a new ChangeMapViewCommand(MapViewChange) command
  applying a wheel/pinch-driven view change, clamped to Min/MaxZoom.
- MapCanvasControl: OnPointerWheelChanged and a PinchGestureRecognizer
  handler, both zooming while keeping the gesture's focal point
  geographically stationary, routed through the new ViewChangedCommand
  (matching the control's existing PointClickedCommand/UndoRequestedCommand
  pattern rather than two-way property binding).
- MapDrawing.DrawTiles: when the exact tile is missing past the source's
  actual max zoom, draws a cropped ancestor tile from the max zoom instead
  ("overzoom" -- standard map-app behavior past native detail).

Verified against the real published Fürstenfeldbruck pack: scrolling in
6 levels past z15 shows a legible overzoomed view (not blank); scrolling
out clamps cleanly at z11 (the pack's real minimum), never blank.

Pinch-to-zoom's scale->zoom-delta math is unit-tested directly
(Avalonia.Headless has no touch/gesture simulation API to drive the full
gesture pipeline).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): require Ctrl for wheel-zoom so plain scroll reaches the page

Root cause (systematic-debugging): the wheel-zoom just added in this same
branch unconditionally captured every wheel event over MapCanvasControl
(e.Handled = true, no modifier check). The map sits inside the
Wasserförderung tab's own ScrollViewer (WasserfoerderungView.axaml) at
360px tall — on a laptop where the window is short enough that the tab
needs to scroll, the cursor is very likely to land on the map while the
operator scrolls the page. Every such scroll got swallowed as a zoom
instead of reaching the ScrollViewer, and a laptop trackpad's rapid
wheel-delta stream during a single scroll swipe could zoom dozens of
levels in an instant — "renders it unreadable," exactly as reported.

Fix: gate wheel-zoom on Ctrl (KeyModifiers.Control), matching how most
embedded maps resolve this exact conflict (Leaflet, Google Maps embeds,
etc.). Plain scroll no longer sets e.Handled, so it bubbles to the
ScrollViewer as normal; Ctrl+scroll still zooms exactly as before,
keeping the cursor's geo point stationary. Pinch-to-zoom is unaffected —
a pinch gesture doesn't conflict with page-scroll the way a plain wheel
notch does.

Verified against the real published Fürstenfeldbruck pack: plain scroll
over the map no longer changes zoom; Ctrl+scroll still zooms in by one
level as designed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(wasserfoerderung): add Ctrl+drag pan and a reset-view control to Karte mode

Root cause (systematic-debugging): cursor-anchored wheel/pinch zoom
shifts the map's center as a side effect (correct, by design), but
MapCanvasControl had no drag-to-pan at all and WasserfoerderungViewModel
never kept the region's initial center/zoom anywhere. Once the view
drifted away from the configured region (trivial after a few zooms near
an edge), there was no way back at all -- matching the report exactly.
Considered Mapsui again; same conclusion as before (first third-party
dependency, blocked on Android's Avalonia pin, much bigger than this
gap needs) -- added the missing controls to the existing hand-rolled map
instead.

- WasserfoerderungViewModel: stores the view it opened with and exposes
  a new ResetMapViewCommand ("ZENTRIEREN") that returns to it.
- MapCanvasControl: Ctrl+left-drag pans (moving the center opposite the
  drag direction, standard map UX), routed through the same
  ViewChangedCommand as wheel/pinch zoom. Reuses the Ctrl convention
  already established for zoom, so it never risks being confused with
  the primary plain-left-click-to-draw-a-route-point gesture.
- Added a small "Strg + Scrollen: Zoom / Strg + Ziehen: Verschieben"
  hint next to the new button, since both interactions are otherwise
  undiscoverable.

Also fixed a real regression these additions exposed: the extra button
and hint line made the tab tall enough to trigger the outer
ScrollViewer's (Fluent overlay-style) vertical scrollbar at window sizes
that previously fit without scrolling. That scrollbar renders on top of
-- not narrowing -- the content, so it silently swallowed clicks on the
map's own right edge. Fixed by reserving a right margin matching the
scrollbar's width, so real content never sits flush against that edge
regardless of what triggers scrolling in the future.

Verified against the real published Fürstenfeldbruck pack: drifting the
view to Berlin, then Ctrl+drag panning and clicking ZENTRIEREN, both
bring it back to Fürstenfeldbruck exactly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwN31QccH98YV9eEc2bue2
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975 added a commit that referenced this pull request Oct 29, 2026
…ddress search (#798)

* feat(karte): download offline Kartenpakete and show them as a map

Groundwork for the Lagekarte in Führung. Stammdaten gains a Karten
section that lists the packs published in CodeForFire/lagebuch-regions,
downloads one per Landkreis onto the device, and shows it as a map that
pans by dragging and zooms by wheel, pinch or keyboard.

The map code is salvaged from #164, which never reached main, and moved
out of the Wasserförderung: MapCanvasControl, the MBTiles reader, the
Web-Mercator math and the pack installer. The #152 review findings that
apply to it are fixed: decoded tiles are cached instead of re-decoded on
every frame, failures surface as German status text, and a pack can be
removed while nothing holds its file open.

A pack belongs to the device, not to the Stammdaten: the Stammdaten
travel to every joined client, and a folder on the host means nothing on
a tablet. So the section acts at once and never marks the editor dirty.

Downloads cross a trust boundary and are treated that way: https only,
the body is cut off at the size the catalogue declared, only
region.mbtiles and region.dem are unpacked under fixed names, and a
failed update leaves the older copy in place. The privacy page lists the
pack download as the fifth way data leaves the device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): keep tile math in double and narrow cleanup catches

Addresses CodeQL alerts 291-296 on #789.

- WebMercator.CenterOfTiles summed tile indices as int before widening.
  The indices come from an MBTiles file that caps the zoom but not the
  columns, so a tampered pack could wrap the int and open the map on the
  wrong side of the world. The arithmetic now runs in double; a test
  replays such a range.
- MapDrawing does the same multiplication in double. The viewport's
  zoom clamp keeps it from overflowing today, but Draw is public.
- RegionPackLibrary's best-effort cleanup catches IOException and
  UnauthorizedAccessException only, with the reason in the block, as
  SessionPdfExport.DeleteQuietly does, instead of an empty catch-all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* test(karte): kill the surviving mutants on the Kartenpakete diff

The mutation gate failed on Domain (72.7 %), Persistence (62.1 %) and
AppLogic (70.3 %). Locally it now reads 100 %, 94.7 % and 94.8 %.

- Boundary tests for GeoPoint, the MBTiles zoom and tile range, and the
  catalogue's caps, field types and bounding box.
- The off-world tile test now stores a tile at the address an unchecked
  lookup would read, so it fails if the guard goes.
- The oversized-body test claimed "no Content-Length" but its
  StreamContent computed one, so the byte-counting cut-off never ran.
  It now sends a body of unknown length; a second test sends a lying one.
- Progress, leftovers of an interrupted install, timeout, an
  undeletable pack, the catalogue address, and the section's selection
  and catalogue rows after install and remove.
- RegionPackInfo.Covers had no caller; removed until address search
  needs it.
- Equivalent mutants carry a Stryker disable with the reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* feat(fuehrung): mark the Einsatzort and the units on a Lagekarte

Führung gains a KARTE tab beside ORGANISATION, FUNKTIONEN and KRÄFTE.
The Lagebuchführer picks the Einsatzort or a unit and taps the map to
place it, or places it in the middle of the map from the keyboard; a
mark already on the map is dragged to move it. Picking and tapping works
the same on a desk and a tablet, where drag and drop does not.

Positions live in the incident, not in the Kartenpaket: Incident.Location
and ForceUnit.Position, saved in four nullable REAL columns (migration
V36, declared in SchemaGuard). A file that stores something other than a
position there loses the mark, not the Einsatz.

The ETB records the Einsatzort being set, moved and removed, with its
coordinates, and a unit's first placement and removal. Moving a unit
already on the map writes nothing: that is tidying the picture, and an
entry per drag would bury the ones that matter.

Two new commands a client may send, setIncidentLocation and
placeForceUnit, so the protocol and its floor rise to 26. Coordinates
cross the wire as plain numbers and are checked on arrival; a half-given
or impossible pair is refused, never read as "take it off".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(fuehrung): keep RegionPackInfo.Covers, the Lagekarte picks its pack with it

#789 dropped Covers while nothing there called it. The Lagekarte does: it
shows the installed pack whose box holds the Einsatzort. Restored with a
test of the box edges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* feat(karte): read Kartenpakete from lagebuch-geodata format 2

The catalogue moves to CodeForFire/lagebuch-geodata's packs.json. A pack
is now checked end to end before it is installed: the zip's SHA-256
against the catalogue, its entries against the six files FORMAT.md
names (anything else refuses the pack rather than being skipped), and
each data file's size and SHA-256 against the pack's own pack.json.
The app's record of the catalogue entry moves to installed.json, since
pack.json is now the publisher's. A pack is current when its version
and checksum match, and the list shows "Stand <Tag> · Version n".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* feat(karte): Hydranten and offline address search on the Lagekarte

A Kartenpaket from lagebuch-geodata carries water.geojson and
addresses.sqlite, and the KARTE tab now uses both.

- Hydranten, Saugstellen, Löschwasserbehälter and Löschteiche are drawn
  over the map from zoom 15 (red dot / blue square, "UH 100" labels
  from 17), behind a HYDRANTEN switch, with "Hydranten aus OpenStreetMap
  – nicht amtlich." under the attribution. Drawn, not controls: a
  Landkreis has thousands.
- An address search over the map reads "Hauptstr 12a Maisach" as
  street, number and place, treats Str./Strasse/Straße alike, ranks the
  exact number and a confirmed place first, and a picked hit marks the
  Einsatzort with the usual ETB entry (read-only: it only centres). It
  starts from the Einsatz's recorded address while nothing is marked.
- Both files are read off the UI thread through IRegionPackLibrary;
  addresses.sqlite is opened read-only with every value bound and LIKE
  wildcards escaped, water.geojson is size- and feature-capped.

The pure map tests in MapCanvasControlTests now run on the Avalonia
thread: touching MapCanvasControl from an xUnit thread raced the
headless thread's InputElement initialisation once more test classes
ran together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): keep the water point radius in double

CodeQL's cs/loss-of-precision flagged 2 * radius as an int product cast to double. The radius is 5 or 7 and cannot overflow, but double literals keep the drawing math in one type, as the tile math already is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): draw every installed Kartenpaket as one map

The KARTE tab showed one pack at a time and switched only when
something was placed or centred, so with FFB and STA installed,
panning across the Landkreis border ran off the edge into blank land.
It also read the installed packs once, when the incident was opened.

- CombinedMapTileSource serves a tile from the first pack that has it,
  so a border is a seam; the attribution lists each distinct licence
  line once.
- Hydranten come from every pack; an unreadable water file costs only
  that pack's points and is reported with its name.
- Opening the KARTE tab re-reads the installed packs, so a pack
  downloaded or deleted under Stammdaten during an Einsatz shows up
  without reopening the incident. The view stays where it was.

Refs #796 (tiles; stitching elevation belongs to the DGM sampler, #587)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): draw each Kartenpaket only within its own area

A pack's edge tiles are only partly map: its OSM data is cut to the
Landkreis plus 3 km before rendering, so the rest of an edge tile is
empty land. Taking a whole tile from the first pack that had one let
FFB's empty margin cover STA's streets, as a cream band across the
Ammersee and the Landkreis Starnberg.

Each pack is now a MapTileLayer drawn clipped to its area (even-odd,
so holes stay holes); in the overlap both packs show the same streets.
The area comes from the zip when a pack carries boundary.geojson, then
declared in pack.json and checked like any data file, and otherwise
from the catalogue's boundaryUrl, fetched once at install over https,
capped at 1 MB and refused unless it is a Polygon or MultiPolygon on
the globe. A pack without a known area is drawn whole, underneath the
others; packs installed before this need AKTUALISIEREN once to get
theirs.

The tile cache is keyed by pack as well, sharing its capacity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): offer AKTUALISIEREN for a pack installed without its area

A pack installed before the catalogue named its boundaryUrl has no area to be clipped to, but matched the catalogue's version and checksum and so showed as INSTALLIERT with no way to fetch it. A different boundaryUrl now makes it outdated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): say why a Kartenpaket is offered for update

AKTUALISIEREN appeared on a pack with the same version number and no explanation (a pack installed before its area was stored). The row now says why: a new version, a rebuild of the same version on another day, or the area still to fetch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* feat(karte): a symbol per water point kind and a card for each

#795 asked for a symbol per kind and a detail view. Hydranten stay red
dots; a Saugstelle is now a blue ring, a Löschwasserbehälter a blue
square and a Löschteich a blue diamond, with a key in the map's corner
whenever they are drawn.

A tap on the map with nothing picked to place opens the card of the
water point under the finger (within a fingertip, only where symbols
are drawn) and rings it; a tap beside it closes the card. The card
lists what OSM holds from FORMAT.md's allowlist -- Bauart, Durchmesser,
Druck, Förderleistung, Volumen, Kupplungen, Lage, Wasser aus, Nummer,
Name, Betreiber, OSM id -- saying the well-known values in German
("Überflur", "DN 150", "Trinkwassernetz") and showing anything else as
OSM spells it, and repeats that OSM is not the Wasserversorger's
register. An OSM reference that is no object id is left off.

WaterPointLayer holds the zoom thresholds and the hit test, so a point
can be tapped exactly when it can be seen.

Closes #795

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): cut each pack file off at the size pack.json declares

#794 listed what a Kartenpaket installer has to withstand. Two pieces
were still missing:

- A single entry was read until the whole pack reached the 2 GB cap and
  only compared with its declared size afterwards. pack.json is now
  unpacked first (capped at 64 KB), and every other file is read only up
  to the size pack.json declares for it, then checked against its
  declared SHA-256. A zip bomb behind a valid outer checksum stops after
  its first chunk.
- A truncated zip had no test. It is refused as "beschädigt" and leaves
  the older copy in place.

A declared size that is negative or not a number, or a checksum that is
not 64 hex digits, refuses the pack before anything else is unpacked.

Closes #794

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* fix(karte): find every street the address search names, in any case

The SQL prefilter capped its candidates at 2000 rows before the street
and place were compared, so a short stem such as "Haupt" filled the cap
with other streets that sort first. The cap now counts matched hits.

SQLite's LIKE folds ASCII only, so "ölmühlweg" never reached Normalize.
The prefix now stops before the first non-ASCII letter and binds the
first letter in both cases.

Search also takes the cancellation token and checks it per row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

* refactor(karte): read a Kartenpaket's area from its zip only

Every pack is rebuilt with boundary.geojson inside it, so the fallback
that fetched the area from the catalogue's boundaryUrl is gone. The area
is now one of the data files pack.json declares, a zip without it is
refused, and it must still parse before the pack is installed.
RegionPackInfo no longer carries BoundaryUrl, so a pack no longer counts
as outdated only because the catalogue started naming its area.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>

---------

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant